package com.huluobo.jetpackkotlindemo.livedata_viewmodel

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider

/**
 * Created by lc on 2022/12/2.
 */
class FragmentA : Fragment() {
    lateinit var shareDataViewModel: ShareDataViewModel
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        shareDataViewModel = ViewModelProvider(this).get(ShareDataViewModel::class.java)
        //标签发生变化时,可以给viewModel中的Position进行赋值
        shareDataViewModel.setCurrentPosition(2)
    }
}